/*This code implements the LCD module */
#include "malta_lcd.h"

void malta_lcd_print(const char* data){
  int i=0;
  malta0->lcdbar.reg = 0xFF;
  for(i=0;i<8 && data[i] != '\0';i++)
    malta0->asciipos[i].value=data[i];
  //if data is too short, complete the display with whitespace
  for(;i<8;i++)
    malta0->asciipos[i].value=0x20;  
}

/* prints data using the position:th led. Returns 1 in case of success, 0 otherwise */
int32_t malta_lcd_print_position(uint32_t position, char data){
  if(position >= 8)
    //we don't have that many leds !
    return 0;
  //sets the corresponding led on (without turning the others off)
  malta0->lcdbar.reg |=  (0x01 << position);
  malta0->asciipos[position].value = data;
  return 1;
}
 



